package o;

import com.huawei.appgallery.assistantdock.storage.db.tables.GameModeWhiteListRecord;
import com.huawei.hms.framework.network.restclient.hwhttp.route.IPRoute;
import java.util.ArrayList;
import java.util.List;

public class bit {
    private static bit ˊ;
    private static final String ˎ = GameModeWhiteListRecord.class.getSimpleName();
    private cfu ˋ = euc.ˊ().ʽ(ˎ);

    public static synchronized bit ˋ() {
        bit o_bit;
        synchronized (bit.class) {
            if (ˊ == null) {
                ˊ = new bit();
            }
            o_bit = ˊ;
        }
        return o_bit;
    }

    private bit() {
    }

    public void ˊ(String str) {
        if (dof.ॱ(str)) {
            Logger.e("GameModeWhiteListDao", "packageName is empty");
            return;
        }
        this.ˋ.ˋ("packageName_=?", new String[]{str});
    }

    private int ˎ(GameModeWhiteListRecord gameModeWhiteListRecord) {
        return this.ˋ.ॱ(gameModeWhiteListRecord, "packageName_=?", new String[]{gameModeWhiteListRecord.ॱ()});
    }

    public void ˋ(String str) {
        if (!dof.ॱ(str)) {
            cfr gameModeWhiteListRecord = new GameModeWhiteListRecord(str);
            gameModeWhiteListRecord.ॱ(System.currentTimeMillis());
            if (ˎ(gameModeWhiteListRecord) <= 0) {
                List ˊ = ˊ();
                if (ˊ != null && ˊ.size() >= IPRoute.INTERVAL) {
                    ˊ(((GameModeWhiteListRecord) ˊ.get(0)).ॱ());
                }
                this.ˋ.ˎ(gameModeWhiteListRecord);
            }
        }
    }

    private List<GameModeWhiteListRecord> ˊ() {
        List<GameModeWhiteListRecord> ˋ = this.ˋ.ˋ(GameModeWhiteListRecord.class, null, null, null, "updateTime_ asc");
        if (CollectCheck.isEmpty(ˋ)) {
            return null;
        }
        return ˋ;
    }

    public List<String> ˎ() {
        List<GameModeWhiteListRecord> ˊ = ˊ();
        if (ˊ == null) {
            return null;
        }
        List<String> arrayList = new ArrayList();
        for (GameModeWhiteListRecord ॱ : ˊ) {
            arrayList.add(ॱ.ॱ());
        }
        return arrayList;
    }
}
